package cn.ording.security;

import org.springframework.dao.DataAccessException;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Component;

import cn.ording.entity.User;

@Component("UserDetailService")
public class MyUserDetailService implements UserDetailsService{

	public UserDetails loadUserByUsername(String username)
			throws UsernameNotFoundException, DataAccessException {
		if(username!=null&&username.trim().equals("haijian")){
			System.out.println("用户:["+username+"] 验证登陆");
			User user = new User();
			user.setUsername("haijian");
			user.setPassword("123");
			return user;
		}else{
			throw new UsernameNotFoundException("用户名不存在");
		}
	}
}
